<%-- 
    Document   : Book
    Created on : 2020-4-17, 10:45:12
    Author     : zhang
--%>

<%@page import="entity.Member"%>
<%@page import="dao.MemberDao"%>
<%@page import="service.FindDiscuss"%>
<%@page import="entity.Discuss"%>
<%@page import="java.util.List"%>
<%@page import="entity.Book"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
            Book book=(Book)request.getAttribute("book");
            
        %>
        <h1><%=book.getBookName()%></h1>
        <div style="position:absolute;left:1000px"><a href="index">返回首页</a></div>
        <div style="width: 200px;height:300px;border:1px solid #000">
            <img src="img/<%=book.getCover()%>" width="200px" height="300px" alt="<%=book.getBookName()%>">
        </div>
        <div style="width: 300px;height:250px;position:absolute;left:230px;top:100px" >
            <p>编号：<%=book.getId()%></p>
            <p>作者：<%=book.getAuthor()%></p>
            <p>出版日期：<%=book.getPublishDate()%></p>
            <p>出版社：<%=book.getPublishHouse()%></p>
            <p>类型：<%=book.getType()%></p>
        </div>
        <div style="width:400px;word-wrap: break-word">
            <p>简介：<%=book.getIntroduction()%></p>
            <p>评分：<%=book.getMark()%>分</p>
        </div>
        <div style="width:400px;word-wrap: break-word"> 
            <p>评论：<a href="discuss.jsp?bookid=<%=book.getId()%>">我要评论</a></p>
            <%
                List<Discuss> list=new FindDiscuss().findDiscussByBookId(book.getId());
                for(Discuss discuss:list){
                    Member member=new MemberDao().getMemberById(discuss.getMemberId());
                    
            %>
            <p><%=member.getName()%>:<%=discuss.getComment()%>
            <%
                if(session.getAttribute("isLogin")!=null){
                    String name=(String)session.getAttribute("username");
                    Member member1=new MemberDao().getMemberByName(name);
                    if(member1.getId()==member.getId()){
            %>
            <a href="dds?id=<%=discuss.getId()%>&bookid=<%=book.getId()%>">删除</a>
            <%
                    }
            }
            %>
            </p>
            <%
                }
            %>
        </div>
        
        <h1 style="position: absolute;left:550px;top:100px">单价：<%=book.getPrice()%>元</h1>
        <div style="position: absolute;left:550px;top:200px">
            <a href="cas?bookid=<%=book.getId()%>"><h3>加入购物车</h3></a><br>
            <a href="Buy.jsp?bookid=<%=book.getId()%>"><h3>立刻购买</h3></a><br>
            <a href="cs?bookid=<%=book.getId()%>"><h3>收藏</h3></a><br>
        </div>
    </body>
</html>
